<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <script>
            const arr1= [1,2,3,4,5,6,2,1];
            const arr2 = [4,5,6,6];
            //1.数组去重
            // const a1 = [...new Set(arr1)];
            // console.log(a1);
            //2.交集
            // const and = [...new Set(arr1)].filter(item=>{
            //     if(new Set(arr2).has(item)){
            //         return true;
            //     }else{
            //         return false;
            //     };
            // });
            // const and = [...new Set(arr1)].filter(item => new Set(arr2).has(item));
            // console.log(and);
            //3.并集
            // const union = [...new Set([...arr1,...arr2])];
            // console.log(union);
            //4.差集
            // const x = [...new Set(arr1)].filter(item=>!new Set(arr2).has(item));
            // console.log(x);
        </script>
    </body>
</html>